package org.zzz.mapper;

import org.apache.ibatis.annotations.*;
import org.zzz.entity.Class;

import java.util.List;

/**
 * @Author ZZF
 * @Time 2021/04/20 22:22
 */
public interface ClassMapper {
    /**
     * 获取所有班级
     * @return
     */
    @Select("select * from class")
    List<Class> listClass();

    /**
     * 根据班级id获取班级名称
     * @param id
     * @return
     */
    @Select("select name from class where id = #{id}")
    String getClassNameById(@Param("id") String id);

    /**
     * 根据班级id获取班级对象
     * @param id
     * @return
     */
    @Select("select * from class where id = #{id}")
    Class getClassById(@Param("id") String id);

    /**
     * 添加班级
     * @param classObject
     * @return
     */
    @Insert("insert into class(id,name) value(#{id},#{name})")
    int insertClass(Class classObject);

    /**
     * 修改班级
     * @param classObject
     * @return
     */
    @Update("update class set name = #{name} where id = #{id}")
    int updateClass(Class classObject);

    /**
     * 根据id删除班级
     * @param id
     * @return
     */
    @Delete("delete from class where id = #{id}")
    int deleteClassById(@Param("id") String id);


}
